package com.shop.cereshop.app.config;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;
import java.util.Map;

/**
 * @description: 自定义序列化器，保持 Long 类型为数字
 * @author zdd
 * @date 2025/11/7 19:01
 * @version 1.0
 */
public class SkuCombinationMapSerializer extends JsonSerializer<Map<String, Long>> {
    @Override
    public void serialize(Map<String, Long> value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        gen.writeStartObject();
        for (Map.Entry<String, Long> entry : value.entrySet()) {
            gen.writeNumberField(entry.getKey(), entry.getValue());
        }
        gen.writeEndObject();
    }
}

